package flc.ast.adapter;

import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.stark.picselect.entity.SelectMediaEntity;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkEmptyProvider;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.utils.TimeUtil;

public class AlbumAdapter extends StkProviderMultiAdapter<SelectMediaEntity> {
    public AlbumAdapter() {
        addItemProvider(new StkEmptyProvider<>(82));
        addItemProvider(new AlbumProvider());
    }

    private class AlbumProvider extends BaseItemProvider<SelectMediaEntity> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_album;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, SelectMediaEntity selectMediaEntity) {
            Glide.with(getContext()).load(selectMediaEntity.getPath()).into((ImageView) baseViewHolder.getView(R.id.ivAlbumItemImg));
            baseViewHolder.setText(R.id.tvAlbumItemLength, TimeUtil.getMmss(selectMediaEntity.getDuration()));
        }
    }
}
